<style>
.iptTime{
 border-top-width:0px;
 border-left-width:0px;
 border-bottom-width:1px;
 border-bottom-style:solid; 
 border-bottom-color:green;
 border-right-width:0px;
 width:18px;
}

.iptTimeH{text-align:right;}
.iptTimeM{text-align:left;}

.iptTimeBlue{
border-top-width:0px;
border-left-width:0px;
border-bottom-width:1px;
border-bottom-style:solid; 
border-bottom-color:blue;
border-right-width:0px;
width:18px;
}
.iptTimeRed{
border-top-width:0px;
border-left-width:0px;
border-bottom-width:1px;
border-bottom-color:red;
border-right-width:0px;
width:18px;
}

</style>


<div id="editor">
<form method="post" action="op.php">
<input type="hidden" name="op" value="admin">
<input type="hidden" name="fp" value="lotto_3s">
<input type="hidden" name="cmd" value="{cmd}">
<input type="hidden" name="id" value="{id}">
<input type="hidden" name="gametype" value="{gametype}">

<table class="tblMy3D" width="800">
<thead class="title0 bgImg_{gametype}">
<tr>
<td colspan="{trColspan}" align="right">{addOnlyOneRound}
<input type="reset" value="重设" name="B2" {btnResetDis} />
<input type="submit" value="确定" name="B1" {btnSubDis} />
{tr01}
</td></tr>
<tr>
<th>*</th>
<th>报表日期</th>
<th>期数</th>
<th>开奖日期</th>
<th>开盘时间</th>
<th>关盘时间</th>
<th>开奖时间</th>
{thShow5N}
</tr>
</thead>
<tbody id="tbdList">
{list3s}
</tbody>
<tfoot class="title0 bgImg_{gametype}">
<tr><td colspan="{trColspan}" style="text-align:right">
<input type="reset" value="重设" name="B2" {btnResetDis} />
<input type="submit" value="确定" name="B1" {btnSubDis} />
{btnUpdateGruop}</td></tr>
</tfoot>
</table>
<div id="msgCalc" class="red"></div>  
<div style="color:red">※ 期数栏位空白时，该笔资料不新增</div>
<div style="color:red">※ 开盘时间，介於春节休市期间之期数将不会新增</div>
</form>
{lotto_3s_chgTime}
</div>

<script>
// 颁奖
$(function(){
  $("input:button#btnCalc").click(function(){
    $("div#msgCalc").text("颁奖中，请稍後...");
    if('{gametype}' == 4){ $("input:button#btnChgTime").attr("disabled","disabled"); }
    $(this).add("input:button#btnStopBetNow").attr("disabled","disabled");
    $.get("?op=admin&fp=xmlSetConf_3d&cmd=calc&id={id}&gametype={gametype}", function(data){
      if(data == "true"){
        $().chkLottoOK(); // 检查是否开奖完成
      }else{
        alert('error');
      }
    });
  });
  editType = {editType};
  if(editType == "true"){
    $("input").not("btnCalc").attr("disabled","disabled");
  
  }
  
  // 根据报表日期 「计算」 期数与开奖日期
  $("input#btnNewPaperDate").click(function(){
    var showNNPaper = {showNNPaper}; 
    
    // 前半日期
    var npaperDate = $("input#newPaperDate").val();
    $("input.inpOpenbet:lt({thisDayLt})").val(npaperDate);    
    
    // 後半日期
    if(showNNPaper == true){
      var npaperDateArr = npaperDate.split("-");
      var nDate = new Date(npaperDateArr[0], npaperDateArr[1]-1, npaperDateArr[2]);
      var nTime = nDate.getTime() + 86400000;
      var nnDate = new Date();
      nnDate.setTime(nTime);
      var nnpaperDate = nnDate.getFullYear() + "-" + (nnDate.getMonth() - 0 + 1) + "-" + nnDate.getDate();
      $("input.inpOpenbet:gt({thisDayGt})").val(nnpaperDate);
    }
    
    // 期数计算
	if({gametype} ==23){
		 var preDate = npaperDateArr[0] + '' + npaperDateArr[1] + '' + npaperDateArr[2];
		  $("input.inpRound:lt(" + ( {thisDayLt} - 0 + 1 ) + ")").each(function(idx,ele){
			var oldRound = $(ele).val();
			var newRound =  preDate + "" + oldRound.substr(8,3);
			$(ele).val(newRound); 
		  });
		  var nexDate = nnDate.getFullYear()+("0" + (nnDate.getMonth() - 0 + 1)).slice(-2) + "" + ("0" + nnDate.getDate()).slice(-2);
		  $("input.inpRound:gt(" + ( {thisDayLt}-1) + ")").each(function(idx,ele){
			var oldRound = $(ele).val();
			var newRound =  nexDate + "" + oldRound.substr(8,3);
			$(ele).val(newRound); 
		  });	
	}
    else if({gametype} > 20 && showNNPaper == true){
      var preDate = npaperDateArr[0] + '' + npaperDateArr[1] + '' + npaperDateArr[2];
      $("input.inpRound:lt(" + ( {thisDayLt} - 0 + 1 ) + ")").each(function(idx,ele){
        var oldRound = $(ele).val();
        var newRound =  preDate + "" + oldRound.substr(8,3);
        $(ele).val(newRound); 
      });
    }else if({gametype} > 10 && showNNPaper == true){
      var preDate = ("0" + npaperDateArr[1]).slice(-2) + "" + ("0" + npaperDateArr[2]).slice(-2);
      $("input.inpRound:lt(" + ( {thisDayLt} - 0 + 1 ) + ")").each(function(idx,ele){
        var oldRound = $(ele).val();
        var newRound =  preDate + "" + oldRound.substr(4,3);
        $(ele).val(newRound); 
      });
       
      var nexDate = ("0" + (nnDate.getMonth() - 0 + 1)).slice(-2) + "" + ("0" + nnDate.getDate()).slice(-2);
      if({gametype} == 14) nexDate = preDate; 
      $("input.inpRound:gt(" + ( {thisDayGt} - 0 + 1 ) + ")").each(function(idx,ele){
        var oldRound = $(ele).val();
        var newRound =  nexDate + "" + oldRound.substr(4,3);
        $(ele).val(newRound); 
      });
    }   
  
  });
  
  
  // 检查是否颁奖完毕
  $.fn.chkLottoOK = function(){
    $.ajax({
      type: 'POST',
      url: '?op=agent&fp=xmlCheckLotto_3d',
      dataType: 'json',
      data: 'id={id}&gametype={gametype}',
      success: function(rdata){
        if(rdata.state=="2"){
          window.top.mainFrame.location.replace("?op=admin&fp=calc_3d&mod={calc}&id={id}&gametype={gametype}"); 
        }else{
          setTimeout("$().chkLottoOK()",1000);   
        }
      }
    });
  };
  
  $("tbody#tbdList tr").hover(
  function() { $(this).addClass("trover"); }
  , function() { $(this).removeClass("trover"); }
  );
  
  $("input:button").hover(
  function() {this.style.color='#0000FF';}
  , function() {this.style.color='';}
  );
  
  
  $("input:button#btnStopBetNow").click(function(){
    $.get("?op=admin&fp=xmlSetConf_3d&cmd=stop&gametype={gametype}&id={id}", function(data){
      if(data == "true"){
        window.top.mainFrame.location.replace("?op=admin&id={id}&cmd=edit&fp=lotto_3s&gametype={gametype}");
      }
    });
  });


  
});

</script>